<?php
declare (strict_types = 1);
namespace app\index\controller;
use think\Request;
use app\model\User as UserModel;
use think\Response;

class User extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {

        $data = UserModel::field('roles,introduction,avatar,name')
        ->page($this->page,$this->pageSize)
        ->select();

        if($data->isEmpty()){
            return $this->create($data,'数据不存在',201);
        }else{
            return $this->create($data,'数据请求成功',201);
        }
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        return $this->create(['name'=>'123'],'访问成功');
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }


    public function test()
    {
        return $this->create(['name'=>'123'],'访问成功');
        //
    }

}
